#!/usr/bin/perl -w

use strict;
use Net::SMTP;
use Data::Dumper;
use Encode 'from_to';
use FindBin '$Bin';
#use lib "$Bin";
#use lib "$Bin/../../perl";
use lib "/data/share/code/trunk/perl/stock/stock_A/stockA_daily_task/mail";
use POSIX;
use MIME::Lite;

my $from = 'flexp2012@163.com';
my $username = 'flexp2012@163.com'; 
my $passwd = 'test123456';
my $smtp_server = 'smtp.163.com';

my $title = "每日数据";
my $task_id = $ARGV[0];
my $mail = `curl \"http://localhost/cgi-bin/task_detail_hold.cgi?task_id=$task_id\"`;

my @tos = map("$_\@163.com",qw/13728733510/);
my @ccs = map("$_\@163.com",qw/flexp2012/);


my $rcv = join(";", @tos);
my $cc = join(";", @ccs);

my $msg = MIME::Lite->new(
    From => $from,
    To => $rcv,
    Cc => $cc,
    Subject => $title,
    Type => 'multipart/related'
);

$msg->attach(Type => 'text/html',
		Data => $mail
		);

MIME::Lite->send('smtp',
    $smtp_server, 
    Timeout=>60, 
    AuthUser=>$username,
    AuthPass=>$passwd);

eval {$msg->send();};

